<template>
<div>
<scroller class="container" @loadmore="loadMore" alwaysScrollableVertical="true">
    <!-- <refresh class="loading" :style="refreshStyle" @refresh="onrefresh()" @pullingdown="onpullingdown" :display="refreshing ? 'show' : 'hide'">
            <loading-indicator class="indicator"></loading-indicator>
    </refresh> -->
      <div class="cell" v-for="(item,index) in formItem">
      <wxc-cell @wxcCellClicked="gotoMap(item)" title="电梯工号">
      <image class="image" slot="label" src="bmlocal://assets/liftId.png"></image>
      <text :style="valueStyle">{{item.lNumber}}</text>
      <image class="locationImg" src="bmlocal://assets/location.png"></image>
      </wxc-cell>

      <wxc-cell @wxcCellClicked="gotoDetail(item)" :has-arrow="true" title="工单编号">
      <image class="image" slot="label" src="bmlocal://assets/orderNumber.png"></image>
      <text :style="valueStyle">{{item.lNumber}}</text>
      </wxc-cell>

      <wxc-cell @wxcCellClicked="wxcCellClicked"
              :has-margin="true" :has-bottom-border="false" title="维保日期">
      <image class="image" slot="label" src="bmlocal://assets/calendar.png"></image>
          { {lNumber:'123'},:'123'},
      <text :style="valueStyle">{{item.lNumber}}</text>
      </wxc-cell>
    </div>
    
    <loading class="loading" @loading="onloading" :display="loadinging ? 'show' : 'hide'">
      <text class="indicator-text">Loading ...</text>
      <loading-indicator class="indicator"></loading-indicator>
    </loading>
  </scroller>
</div>
  
</template>

<script>
  const modal = weex.requireModule('modal')
  import { WxcCell} from 'weex-ui';
  export default {
    components:{
       WxcCell,
    },
    data () {
      return {
        loadinging: false,
        token:'',
        formItem: [{lNumber:12123},
                        {lNumber:12123},
                        {lNumber:12123},
                        {lNumber:12123},
                        {lNumber:12123},
                        {lNumber:12123},],
        filter:{}
      }
    },
    methods: {
      onloading (event) {
        modal.toast({ message: 'Loading', duration: 1 })
        this.loadinging = true
        setTimeout(() => {
          this.loadinging = false
        }, 2000)
      },
      loadMore(){
        modal.toast({ message: 'Loading', duration: 1 })
      },
      getPolicyList(refresh){
            this.filter.page = 1
            this.filter.pageSize = 10
            this.$fetch({
                header:{
                    'Content-Type': 'application/x-www-form-urlencoded',
                    'Authorization': `Bearer `+ this.token
                },
                method: 'POST',    
                name: 'myUpkeepList',
                data: this.filter
            }).then(resData => {
                if(resData.success){
                    // if(refresh){
                    //     this.formItem = resData.data.content
                    // }else{
                    //     this.formItem = this.formItem.concat(resData.data.content)
                    // }
                    // this.totalPages = resData.data.totalPages
                    // if(!this.filter){
                    //     this.$storage.set('myPolicyList', JSON.stringify(resData.data.content))
                    // }
                    this.formItem = [{lNumber:222222},
                        {lNumber:22},
                        {lNumber:22},
                        {lNumber:22},
                       ]
                }else{
                    this.$notice.toast({
                        message: '网络错误'
                    })
                }
            }, error => {
                this.$notice.toast({
                    message: '网络错误'
                })
            })
            
            this.$notice.loading.hide()
            setTimeout(() => {
                this.refreshing = false
                this.loadinging = false
            }, 500)
      }
    },
    created(){
       // 获取token
        this.token = this.$storage.getSync('token')
        if(!this.token){
            this.$router.setHomePage('/pages/login.js')
        }
        this.getPolicyList(true)
      this.lists = [1,2,3,4,5,6]
    }
  }
</script>

<style scoped>
  .loading {
    width: 750;

    display: -ms-flex;
    display: -webkit-flex;
    display: flex;
    -ms-flex-align: center;
    -webkit-align-items: center;
    -webkit-box-align: center;
    align-items: center;
  }
  .indicator-text {
    color: #888888;
    font-size: 42px;
    text-align: center;
  }
  .indicator {
    /* margin-top: 16px; */
    height: 80px;
    width: 80px;
    color: #f49428;
}
  .panel {
    width: 600px;
    height: 250px;
    margin-left: 75px;
    margin-top: 35px;
    margin-bottom: 35px;
    flex-direction: column;
    justify-content: center;
    border-width: 2px;
    border-style: solid;
    border-color: #DDDDDD;
    background-color: #F5F5F5;
  }
  .text {
    font-size: 50px;
    text-align: center;
    color: #41B883;
  }
  .container {
    /* flex: 1; */
    width: 750px;
    background-color: #f2f3f4;
}
</style>